using QFramework;
namespace GameJamLight
{
    public interface ILevelTimingSystem : ISystem
    {
        BindableProperty<int> CurLevelTime { get; }

        void Start();
        void Stop();
    }

    public class LevelTimingSystem : AbstractSystem, ILevelTimingSystem
    {
        public BindableProperty<int> CurLevelTime { get; } = new BindableProperty<int>(0);

        private Timer levelTimer;

        public void Start()
        {
            CurLevelTime.Value = 0;
            levelTimer.Start(1f, true, () => CurLevelTime.Value++);
        }

        public void Stop() => levelTimer.Stop();

        protected override void OnInit()
        {
            levelTimer = new Timer();
            PublicMono.Instance.OnUpdate += levelTimer.Update;
        }
    }
}